package core;

/**
 * Trida reprezentujici film
 * @author vojta
 */
public class Movie {

    private int id;
    private String name;
    private int year;
    private String director;
    private Medium medium;
    private Genre genre;

    public Movie(int id, String name, int year, String director, Medium medium, Genre genre) {
        this.id = id;
        this.name = name;
        this.year = year;
        this.director = director;
        this.medium = medium;
        this.genre = genre;
    }

    public Movie(String name, int year, String director, Medium medium, Genre genre) {
        this.name = name;
        this.year = year;
        this.director = director;
        this.medium = medium;
        this.genre = genre;
    }

    public Movie(int id) {
        this(id,"",0,"",null,null);
    }

    public String getDirector() {
        return director;
    }

    public void setDirector(String director) {
        this.director = director;
    }

    public Genre getGenre() {
        return genre;
    }

    public void setGenre(Genre genre) {
        this.genre = genre;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Medium getMedium() {
        return medium;
    }

    public void setMedium(Medium medium) {
        this.medium = medium;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    @Override
    public String toString() {
        String r = "id: " + this.id + " name: " + this.name + " Year: " + this.year + " Director: " + this.director + "" +
                " medium :" + medium.getMedium() + " genre: " + genre.getGenre();
        return r;
    }

    public String toXML() {
        String xml = "\n    <movie> \n" +
                "       <id>"+ this.id +"</id> \n" +
                "       <name>"+ this.name +"</name> \n" +
                "       <year>"+ this.year +"</year> \n" +
                "       <director>"+ this.director +"</director> \n" +
                "       <medium id=\"" + this.medium.getId() + "\" name=\"" + this.medium.getMedium() + "\" /> \n" +
                "       <genre id=\"" + this.genre.getId() + "\" name=\"" + this.genre.getGenre() + "\" /> \n" +
                "   </movie> \n";
        return xml;
    }

    public String toHTML() {
        String html = "<tr><td>"+ this.id +"</td><td>"+ this.name +"</td><td>"+ this.year +"</td>" +
                "<td>"+ this.director +"</td><td>"+ this.medium.getId() +"</td><td>"+ this.medium.getMedium() +"</td>" +
                "<td>"+ this.genre.getId() +"</td><td>"+ this.genre.getGenre() +"</td></tr>\n";
        return html;

    }
    

}
